package ferp.core.calc.scorer;

import ferp.core.calc.Calculator;
import ferp.core.game.Game;
import ferp.core.game.Settings;
import ferp.core.player.Player;

/**
 * User: olegs
 * Date: 12/3/13 2:02 PM
 */
public class TrickingTwoPasses extends Scorer
{
  public static final TrickingTwoPasses instance = new TrickingTwoPasses();

  @Override
  protected void update(Game g, Settings settings, Calculator c)
  {
    c.writeToPool(g, settings, g.declarer(), c.getPlayCostSuccess(g.contract()));
  }

  @Override
  protected void statistics(Game g)
  {
    int contract = g.contract();

    for (Player p : g.players())
      if (p == g.declarer())
        // add contract tricks to aggregation and not a declarer tricks (as it equal to 10)
        g.statistics.updateTricking(p.id(), contract, contract);
      else
        g.statistics.passes[p.id()]++;
  }
}
